﻿@{
    ViewData["Title"] = "传统文书检索";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@section head{
    <link href="/css/bootstrap.min.css?v=3.3.6" rel="stylesheet" />
    <link href="/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" />
    <link href="/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet" />
    <link href="/css/animate.min.css" rel="stylesheet" />
    <link href="/css/style.min.css?v=4.1.0" rel="stylesheet" />
    <link href="/css/select2/select2.min.css" rel="stylesheet" />
    <style type="text/css">
        .dSearch .btn {
            margin-top: -3px;
        }

        .dSearch .form-control {
            display: inline-block;
        }

        .dSearch .layer-date {
            margin-top: -7px;
        }

        .dataTables_wrapper {
            padding-bottom: 0px;
        }

        div.dataTables_scrollBody table {
            margin-top: -18px !important;
        }

        .fixed-table-pagination .pagination-detail, .fixed-table-pagination div.pagination {
            margin-bottom: 0px;
        }

        .card_table tbody tr td {
            border: none;
        }

        #dSearch table tr td {
            padding: 8px;
        }

        #dSearch .input-group {
            width: 100%;
        }

        #dSearch .input-group-addon {
            width: 100px;
        }

        #dSearch .fix-border {
            border-left: none;
            border-right: none;
        }

        .fixed-table-toolbar .search {
            width: 200px;
        }

        #searchbtn {
            margin-top: 10px;
            font-size: 10pt;
            line-height: 16px;
            height: 30px;
        }
    </style>
}
<form id="form1" runat="server">
    <div id="dMain">
        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="ibox" style="margin-bottom: 0px;">
                <div class="ibox-title">
                    <h5>传统文书数据检索</h5>
                </div>
                <div class="ibox-content">
                    <div id="collapseOne" class="panel-collapse collapse">
                        <div class="panel-body">
                            <div class="dSearch">
                                @*<asp:TextBox ID="txtFileNo" runat="server" CssClass="form-control" placeholder="档号" Width="130"></asp:TextBox>*@
                                <input type="text" id="txtFileNo" class="form-control" placeholder="档号" style="width:130px;" />
                                @*<asp:TextBox ID="txtND1" runat="server" CssClass="form-control" Width="85" placeholder="开始年度" onclick="WdatePicker({dateFmt: 'yyyy'})"></asp:TextBox>*@
                                <input type="text" id="txtND1" class="form-control" style="width:80px;" placeholder="开始年度" onclick="WdatePicker({dateFmt: 'yyyy'})" />
                                至
                                @*<asp:TextBox ID="txtND2" runat="server" CssClass="form-control" Width="85" placeholder="结束年度" onclick="WdatePicker({dateFmt: 'yyyy'})"></asp:TextBox>*@
                                <input type="text" id="txtND2" class="form-control" style="width:80px;" placeholder="结束年度" onclick="WdatePicker({dateFmt: 'yyyy'})" />
                                @*<asp:DropDownList ID="ddlFTerm" runat="server" CssClass="form-control" Width="100"></asp:DropDownList>*@
                                <select id="ddlFTerm" class="form-control" style="width:100px;" placeholder="期限"></select>
                                @*<asp:DropDownList ID="ddlFType" runat="server" CssClass="form-control" Width="130"></asp:DropDownList>*@
                                <select id="ddlFType" class="form-control" style="width:130px;" placeholder="机构或问题"></select>
                                @*<asp:TextBox ID="txtTM" runat="server" CssClass="form-control" placeholder="题名" Width="180"></asp:TextBox>*@
                                <input type="text" ID="txtAllSearchMsg" Class="form-control" placeholder="关键字,多个关键字用','隔开" style=" width: 200px;" />
                                @*<asp:TextBox ID="txtZZ" runat="server" CssClass="form-control" placeholder="作者" Width="130"></asp:TextBox>*@
                                @*<input type="text" ID="txtZRZ" Class="form-control" placeholder="责任者" style="width:130px;" />*@
                                @*<asp:TextBox ID="txtSFWH" runat="server" CssClass="form-control" placeholder="收发文号" Width="100"></asp:TextBox>--%>*@
                                @*<asp:TextBox ID="txtAllSearchMsg" runat="server" CssClass="form-control" placeholder="关键字,多个关键字用','隔开" Width="200"></asp:TextBox>*@
                                @*<asp:LinkButton ID="lbtnSearch" runat="server" CssClass="btn btn-sm btn-primary" OnClick="lbtnSearch_Click"><i class="icon-search"></i>&nbsp;检索</asp:LinkButton>*@
                                <button type="button" style="margin-left:50px" id="btn_query" class="btn btn-sm btn-primary">&nbsp;检索</button>
                            </div>
                        </div>
                    </div>
                    <div id="toolbar">
                        <a data-toggle="collapse" data-parent="#accordion" id="searchbtn" class="btn btn-sm btn-primary" href="#collapseOne">检索</a>
                        <a class="btn btn-sm btn-primary btn-pd" onclick="Apply()" style="margin-top: 10px;">阅卷申请</a>
                    </div>
                    <table id="tabData" class="table table-bordered" style="width: 2000px;">
                        <thead>
                            <tr>
                                <th>#</th>
                                <th>档号</th>
                                <th>期限</th>
                                <th><%=FLName %></th>
                                <th>案卷号</th>
                                <th>题名</th>
                                <th>文号</th>
                                <th>责任者</th>
                                <th>页数</th>
                                <th>归档年度</th>
                                <th>文件形成时间</th>
                                <th>归档日期</th>
                                <th>档案门类代码</th>
                                <th>全宗名称</th>
                                <th>全宗号</th>
                                <th>控制标识</th>
                                <th>密级</th>
                                <th>状态</th>
                            </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                    <hr style="height: 1px; border: none; border-top: 1px dashed #1E90FF; margin-top: 3px; margin-bottom: 5px;" />
                    <table id="tabData2" class="table table-bordered" style="width: 100%;">
                        <thead>
                            <tr>
                                <th>#</th>
                                <th>序号</th>
                                <th>文件作者</th>
                                <th>收发文号</th>
                                <th>题名</th>
                                <th>文件日期</th>
                                <th>页码</th>
                                <th>备考</th>
                            </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</form>
@section scripts{
    <script src="/js/jquery.min.js?v=2.1.4"></script>
    <script src="/js/bootstrap.min.js?v=3.3.6"></script>
    <script src="/js/plugins/jeditable/jquery.jeditable.js"></script>
    <script src="/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
    <script src="/js/plugins/bootstrap-table/bootstrap-table-export.js"></script>
    <script src="/js/plugins/bootstrap-table/tableExport.js"></script>
    <script src="/js/plugins/bootstrap-table/bootstrap-table-cookie.js"></script>
    <script src="/js/content.min.js"></script>
    <script src="/js/My97DatePicker/WdatePicker.js"></script>
    <script src="/js/plugins/layer/layer.min.js"></script>
    <script src="/js/store.js"></script>
    <script src="/js/verification.js"></script>
    <script src="/js/select2/select2.min.js"></script>
    <script src="/js/zuiCode.js"></script>

    <script type="text/javascript">
        var tabHeight = 0;
        $(function () {
            tabHeight = (GetHeight() - 140) / 2//将两个表格平分高
            //var tabHeight = document.documentElement.clientHeight - 130 - 250;

            $('#tabData').bootstrapTable({
                height: tabHeight + 50,
                data: $("#dJson").text() != "" ? JSON.parse($("#dJson").text()) : "",
                dataType: "json",
                columns: [
                    { align: 'center', width: "50px", checkbox: true },
                    { align: 'left', width: "150px", sortable: true, formatter: operateFormatter2 },
                    //{ field: 'FileNo', align: 'left', width: "150px", sortable: true },
                    { field: 'FTermName', align: 'center', width: "100px", sortable: true },
                    { field: 'FType', align: 'center', width: "150px" },
                    { field: 'FRef', align: 'center', width: "80px", sortable: true },
                    { field: 'Title', align: 'left', width: "0" },
                    { field: 'ArticleNo', align: 'center', width: "80px" },
                    { field: 'ResponsiblePerson', align: 'center', width: "80px" },
                    { field: 'PageCount', align: 'center', width: "80px" },

                    { field: 'FYear', align: 'center', width: "100px", sortable: true },
                    { field: 'ArticleDate', align: 'center', width: "100px", sortable: true },
                    { field: 'KeptFileDate', align: 'center', width: "100px", sortable: true },

                    { field: 'DAMLDM', align: 'center', width: "100px", sortable: true },
                    { field: 'QZMC', align: 'center', width: "100px", sortable: true },
                    { field: 'QZH', align: 'center', width: "100px", sortable: true },
                    { field: 'KZBS', align: 'center', width: "100px", sortable: true },

                    { field: 'MLevel', align: 'center', width: "80px" },
                    { align: 'center', width: "80px", sortable: true, formatter: fileState }
                ],
                toolbar: '#toolbar',//工具按钮用哪个容器
                buttonsClass: "sm btn-white",//按钮class
                pageSize: 100,//分页条数
                clickToSelect: true,//设置true 将在点击行时，自动选择单选或复选框
                singleSelect: false,//为true则禁止多选
                cache: false,//是否缓存
                cookie: false,//是否启用cookie
                cookieIdTable: "InsSearch1",//cookie键值
                pagination: true,//是否分页
                pageNumber: 1,
                clickToSelect: true,
                showColumns: true,//是否显示所有的列
                showRefresh: true,//是否显示刷新按钮
                search: true,//是否启用搜索
                showPaginationSwitch: true,//是否显示分页切换按钮
                showExport: true,//是否启用导出
                striped: true,//是否显示行间隔色
                responseHandler: function (msg) { //数据加载转换
                    if (msg) {
                        return {
                            "total": msg.total,//总页数
                            "rows": msg.rows //数据
                        };
                    }
                    else {
                        showTip("数据加载失败！", 2);
                    }
                },
                onDblClickRow: function (row, obj) { //双击行事件
                    if (row.Flag3 != 1) {
                        window.top.showFullPage("图像阅读器（" + (row.FileNo) + "）", "/See.aspx?FID=" + row.ID);
                    }
                    else if (row.Flag3 == 1) {
                        showTip("档案被封存,无法查看原文件", 2, 2);
                    }
                },
                onClickRow: function (row, obj) { //单击行事件
                    $(obj).parent().find("tr").removeClass("selected");
                    $(obj).addClass("selected");

                    //根据选中的行获取子表数据
                    GetSonData(row.ID, row.Flag3);
                },
                onSearch: function (text) {
                    if (text != "") {
                        $("#tabData tbody tr td:not(.bs-checkbox)").each(function (i) {
                            var str = "<span class=\"bg-yellow\">" + text + "</span>";
                            var NewText = $("#tabData tbody tr td:not(.bs-checkbox)").eq(i).text().replaceAll(text, str);
                            $("#tabData tbody tr td:not(.bs-checkbox)").eq(i).html(NewText);
                        })
                    }
                }
            });

            $('#ddlFType').select2();
            $('#ddlFTerm').select2();

            function fileState(value, row, index) {
                if (row.Flag3 == 0) {
                    return ["<p class=\"text-success\">正常</p>"];
                }
                else if (row.Flag3 == 1) {
                    return ["<p class=\"text-danger\">封存</p>"];
                }
            }
        });

        function operateFormatter2(value, row, index) {
            if (row.Flag3 != 1) {
                return [
                    "<i class=\"fa fa-file-picture-o\" style='color: " + (row.PageNum != 0 ? "#38B03F" : "#bbb") + "'></i>&nbsp;"
                    + "<a href=\"javascript:;\" onclick=\"window.top.showFullPage('图像阅读器（" + (row.FileNo) + "）', 'See.aspx?FID=" + row.ID + "&DirID=0');\">" + (row.FileNo) + "</a>"
                ];
            }
            else {
                return [
                    "<i class=\"fa fa-file-picture-o\" style='color: " + (row.PageCount1 != 0 ? "#38B03F" : "#bbb") + "'></i>&nbsp;"
                    + "<a href=\"javascript:;\">" + (row.FileNo) + "</a>"
                ];
            }
        }


        //阅卷申请
        function Apply() {
            var FilesApply_FIDS = "";
            $.map($('#tabData').bootstrapTable('getSelections'), function (row) {
                if (FilesApply_FIDS == "") {
                    FilesApply_FIDS += row.ID;
                }
                else {
                    FilesApply_FIDS += "," + row.ID;
                }
            });

            if (FilesApply_FIDS != "") {
                store.set("FilesApply_FIDS", FilesApply_FIDS);
                showPage("阅卷申请", "/FilesApply/Apply.aspx", 700, 500, false);
            }
        }

        //获取子表数据
        function GetSonData(_FID, fileState) {
            DataLoading();
            $.ajax({
                type: "post",
                url: "ashx/Files.ashx",
                dataType: "json",
                async: true,
                data: { type: "GetInsSearch1Dir", FID: _FID },
                success: function (msg) {
                    if (msg.result == 1) {
                        $('#tabData2').bootstrapTable('destroy');
                        $('#tabData2').bootstrapTable({
                            height: tabHeight - 50,
                            data: msg.JsonData != "" ? JSON.parse(msg.JsonData) : "",
                            dataType: "json",
                            columns: [
                                { align: 'center', width: "50px", checkbox: true },
                                { field: 'DirIndex', align: 'center', width: "50px" },
                                { field: 'Responsibilityer', align: 'left', width: "160px" },
                                { field: 'ArticleNo', align: 'left', width: "160px" },
                                { field: 'DirName', align: 'left', width: "0" },
                                { field: 'DirDate', align: 'center', width: "80px" },
                                { field: 'PageNo', align: 'center', width: "50px" },
                                { field: 'Remark', align: 'left', width: "100px" }
                            ],
                            //toolbar: '#toolbar',//工具按钮用哪个容器
                            buttonsClass: "sm btn-white",//按钮class
                            //pageSize: 100,//分页条数
                            clickToSelect: false,//设置true 将在点击行时，自动选择单选或复选框
                            singleSelect: false,//为true则禁止多选
                            cache: false,//是否缓存
                            cookie: true,//是否启用cookie
                            cookieIdTable: "InsSearch1Tab2",//cookie键值
                            pagination: false,//是否分页
                            showColumns: false,//是否显示所有的列
                            showRefresh: false,//是否显示刷新按钮
                            search: false,//是否启用搜索
                            showPaginationSwitch: false,//是否显示分页切换按钮
                            showExport: false,//是否启用导出
                            striped: false,//是否显示行间隔色
                            detailView: false,//是否显示切换视图列
                            onDblClickRow: function (row, obj) { //双击行事件
                                if (fileState != 1) {
                                    window.top.showFullPage('图像阅读器（' + (row.FileNo) + '）', 'See.aspx?FID=' + (row.FID) + '&DirID=' + (row.ID));
                                }
                                else if (fileState == 1) {
                                    showTip("档案被封存,无法查看原文件", 2, 2);
                                }
                            }
                        });

                        $("#htmlTip").remove();
                    }
                }
            });
        }
    </script>
}
